科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道应用软件在 Python中使用 cout << 'Hello,world!' << endl

在 Python中使用 cout << 'Hello,world!' << endl

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

在 Python中使用 cout << 'Hello,world!' << endl

作者:albertlee 来源:CSDN 2008年5月21日

关键字: cout 使用 python 软件

  • 评论
  • 分享微博
  • 分享邮件
 

import sys

class ostream:
    def __init__(self,file):
        self.file = file

    def __lshift__(self,obj):
        self.file.write(str(obj));
        return self

cout = ostream(sys.stdout)
cerr = ostream(sys.stderr)
endl = '\n'


age = 23
name = 'albert'

cout << 'Hello,world!' << endl

cout << 'Name:' << name << endl << 'Age:' << age << endl

    • 评论
    • 分享微博
    • 分享邮件
    閭欢璁㈤槄

    濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�

    重磅专题
    往期文章
    最新文章